package Application.serviceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import Application.dao.DiscussDao;
import Application.entity.Discuss;
import Application.entity.Result;
import Application.service.DiscussService;
@Service("DiscussService")
public class DiscussServiceImpl implements DiscussService {

	@Resource
	private DiscussDao dao;
	
	@Override
	public Result insertDiscuss(Discuss discuss) {
		Result r = new Result();
		try {
			String time=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			discuss.setDate(time);
			dao.insertDiscuss(discuss);
			r.setContent(1);
		} catch (Exception e) {
			r.setContent(0);
		}
		return r;
	}

	@Override
	public List<Discuss> findDiscussByEssayId(int essayid) {
		return dao.findDiscussByEssayId(essayid);
	}

}
